#pragma once
#include <string>
#include <vector>
#include <map>
using namespace std;

typedef unsigned int uint;

class strPool
{
public:
    map<string,uint> pool;
    map<uint,string> revPool;
    uint find(string str)
    {
        auto iter=this->pool.find(str);
        if(iter != this->pool.end())
            return iter->second;
        else
        {
            uint ret=pool.size();
            this->pool[str]=ret;
            this->revPool[ret]=str;
            return ret;
        }
    }

    string revFind(uint i) { return this->revPool[i]; }
};


enum class valueStat : char { zero, one, x, z };
class value
{
public:
    valueStat unitValue;
    vector<valueStat> multiValue;
    bool isUnit;
    value(valueStat unitValue) : unitValue(unitValue), isUnit(true) {}
    value(vector<valueStat> multiValue) : multiValue(multiValue), isUnit(false) {}

    void toNormal(vector<bool> comp)
    {
        //fix:解压到multiValue
    }

    vector<bool> toCompress()
    {
        //fix:压缩后变为vector<bool>
    }

    static valueStat toValueStat(char c)
    {
        if(c=='0')
            return valueStat::zero;
        else if(c=='1')
            return valueStat::one;
        else if(c=='x')
            return valueStat::x;
        else if(c=='z')
            return valueStat::z;
    }
};


class vcd
{
public:
    string fileHead;
    vector<string> allSignalName;
    void addSignalName(string name) { this->allSignalName.push_back(name); }
    vector<uint> allTime; //偶数位为时间差值，奇数位为该时刻变化信号数
    vector<value> allValue;
    void reset()
    {
        fileHead.clear();
        allSignalName.clear();
        allTime.clear();
        allValue.clear();
    }
};
